<html>
<head>
<script src="resources/jquery-1.6.min.js"></script>
<script>
$(function(){
var txtName = $("<input>").appendTo("body"),
	txtPwd = $("<input>").appendTo("body"),
	btnLogin = $("<button>").text("login").appendTo("body").click(function(){
		$.ajax({
			url:'test/login',
			type:'post',
			data:{name:txtName.val(),pwd:txtPwd.val()},
			success:function(account){
			
				$("<button>").text("logout").click(function(){
					$.ajax({
						url:'test/logout',
						type:'get',
						success:function(){
							location.href="/org.phantom.simpledemo/index.html";
						},
						error:function(){
						}
					});
				}).prependTo($("body").empty().append($("<span>")));
				
				$("<button>").text("you logined,test get permission").click(function(){
					$.ajax({
						url:'test/test/read',
						type:'get',
						success:function(){
							$("span").empty().text("you has permission");
						},
						error:function(){
							$("span").empty().text("you had not enough permission");
						}
					});
				}).prependTo($("body"));
				$("<button>").text("you logined,test delete permission").click(function(){
					$.ajax({
						url:'test/test/delete',
						type:'delete',
						success:function(){
							$("span").empty().text("you has permission");
						},
						error:function(){
							$("span").empty().text("you had not enough permission");
						}
					});
				}).prependTo($("body"));
				
				
				$("<button>").text("test dynimic url").click(function(){
					$.ajax({
						url:'test/param/2',
						type:'get',
						success:function(){
							$("span").empty().text("test success");
						},
						error:function(){
							$("span").empty().text("test failed");
						}
					});
				}).prependTo($("body"));
			}
		});
	});
});
</script>
</head>
<body>
</body>
</html>